Copyright: PrintFile 2.0  Copyright 1996-1997 by Peter Lerup


Contents
PrintFile

Version 2.1.5

Copyright 1996-2001 by Peter Lerup. All rights reserved

Contents

Overview

What is new

Installation

Printing Files

Program Settings

Run as a print spooler

Frequently asked questions

Technical information

Legal Issues

Author


Overview

PrintFile is a freeware utility program that will enable you to print files fast and easily. The program recognizes plain text, PostScript, Encapsulated PostScript (EPS) and binary formats.

Selection of which files to print can be made by the normal Windows file selection dialog, or by Drag and Drop operations with one or several files. The latter facilitates batch printing of files.

PrintFile can also act as a print spooler, watching a specified directory for files. Whenever a file appears in that directory it will automatically be printed.

When printing text files PrintFile makes a configurable page layout of the text contents. Several logical pages can be placed on one page of physical paper (referred to as n-up printing). There are also several other configurable options controlling the layout. Text files can be printed on any printer which has a Windows printer driver. Text copied to the clipboard can also be printed in the same manner as text files. PrintFile can also do user configurable Pretty Printing of text files. Keywords and comments can be highlighted using different font styles and colors. This function is primarily intended for source code files.

Non-text files are sent files directly to a Windows printer. In this case the program can be seen as a Windows replacement for the DOS command "copy/b filename LPTx" . However, unlike the DOS command, PrintFile works well with network printers that do not have a connection to any LPTx. Although this function is mainly intended for printing PostScript files, it could be used just as well for any file created by the "Print to File" option available for most Windows printer drivers. Such a print file can for instance be created on a PC without a printer and then be moved to another PC that has a printer, and there be sent to the printer using PrintFile.

PostScript files can normally only be printed on PostScript printers. If a conversion program like Ghostscript is available however, PrintFile can automatically make a conversion before sending the file to the printer. The program can also print Encapsulated PostScript Files (EPS). These files can normally only be inserted into documents and not be printed directly. It is also possible to control the positioning and layout of the EPS picture on the printer page. Both EPS files with and without preview can be handled. Other PostScript features are the possibility to select an arbitrary range of pages for the printout when printing multiple page PostScript files and to do n-up printing. By using a properly configured Windows PostScript driver connected to a file, this function can be used to get n-up printing from almost every Windows program.

PostScript and EPS files created on Macintosh and UNIX systems can also be printed by PrintFile.

PrintFile also works well with command line (DOS) programs. It has several command line options and can read data from command line standard input, e.g. a command line pipe. A command like

dir | prfile32

can for instance be used to get a n-up printout of a directory listing (only in Windows 95 and NT).

The program is available in both 16-bit (Windows 3.1x) and 32-bit (Windows 95 and NT) versions.

A word of warning!

PrintFile is a poweruser tool and should be used with care. It is important that non-text files that are sent to a printer are intended for that type of printer.


What is new
What is new in PrintFile versions?

Version 2.1.5

Version 2.1.5 is a very small update of 2.1.4.

New and corrected functions:

º When printing text files in earlier versions of PrintFile it has only been possible to specify either the number of lines that should fit into one logical page, or the number of characters that should fit into one line of text. The standard ratio for the font implicitly selected the value that was not specified. In this version however, it is possible to specify both values, and in that case the character ratio will be adjusted accordingly.

º A minor bug in the de-installation program, that in some cases prevented the removal of the PrintFile entry in the "Add/Remove Programs" control panel dialog, has been fixed.

Version 2.1.4

Version 2.1.4 is a minor update of 2.1.3.

New and corrected functions:

º It is now possible to associate a named setting with a specific file extension.

º New option that enables creation of a PrintFile icon in the taskbar (a.k.a. system tray). This icon can be used for quick access to the programs menu and to activate or hide its window.

º The spooler function now doesn't start the printing of a file until it's available for exclusive access, i.e. no premature printing of files before the program producing them are ready.

º New qualifier for specifying default number of copies introduced.

º The n-up handling of PostScript files have been improved to handle more violent PostScript files, e.g. PostScript printer driver files produced by Adobe Acrobat can now be printed n-up.

º Individual tab settings can now be specified in the pretty print definition file.

º The copy count specified in the printer dialog now works for all type of printers.

º Better handling of form feed characters and strange CR/LF combinations in text files.

º Correct handling of form feed characters in text files.

Version 2.1.3

Version 2.1.3 is a minor update of 2.1.2

New and corrected functions:

º Added possibility to associate PrintFile with certain file extensions when installing

º Enabled selection of multiple files in the standard Windows file selection dialog

º MS DOS text graphics files can now be printed correctly with the font MS LineDraw

º The program is now always brought to front when drag and drop has been performed

º Removed limitation of number of pretty print keywords in the 16 bit version

º Activating the "Print to file" option in the standard printer selection dialog now works

º Different collation of copies now works as expected

º Removed dummy error message appearing when running through a pipe with RedMon on NT

Version 2.1.2

Version 2.1.2 is a bug fix version of 2.1.1 The following malfunctions have been corrected:

º Added a fix for n-up printing of PostScript files generated by the Windows 95 PostScript printer driver

º Removed extra linefeed after the terminating end-of-file character when printing PostScript files

º Keyboard input now works in the standard printer selection dialog

º Possible to use file names with "@" on the command line

Version 2.1.1

Version 2.1.1 is a bug fix version of 2.1. The following malfunctions have been corrected:

º Fixed a bug that might cause a crash when pretty printing files with line wrap disabled

º Wildcard file names on the command line are now handled correctly also in the 32-bit version.

º Underscore is now a valid character in pretty print keyword definitions

º Added a fix for n-up printing of PostScript files generated by the new Adobe PostScript printer driver version 5.0. Please note however that PrintFile can not do additional n-up printing of files that have been generated using the n-up function in the Adobe driver

Version 2.1

New functions:

º Possible to let a conversion program, e.g. Ghostscript, convert each file before printing

º Print clipboard text contents

º Print data from standard input, e.g. a command line pipe

º User configurable Pretty Printing of text files

º Install / uninstall option

º Possible to include Windows printer driver prolog when printing PostScript files

º Right button popup menu

º Different window types with Always on Top option

º File information preview

º Optional progress bar

º Bypassing the printer driver in the 16-bit version giving faster and more reliable functionality

º Better file type detection

º Temporary changes of settings possible (Apply)

º Optional log file

º Text size can be specified either by lines per page or characters per line

º Dimension units according to Windows settings (mm or inch)

º True word wrap of long lines instead of character wrap

º Possible automatic OEM translation of text files

º Form-feeds in text files are now recognized

º Paper or logical page bound header and footer can be used

º Some more minor changes in functionality and layout

Bug fixes:

º Workaround for some HP-printer drivers that only produces empty rectangles when frames used in text printing.

º Last page footer placed correctly.

º Total page count is now correct.

º Fixed problem with 16-bit version refusing to start on Windows 3.1x running IBM DOS 7

Version 2.0

New functions:

º Formatted text file printing

º N-up printing of PostScript files

º More advanced settings management

º Spooler function

º Prolog file can be used when printing PostScript files

º Desktop and Send to shortcuts can be created automatically

º List files and wildcards can be given on the command line

º Possible to select a non default specific printer also in the 16-bit version

Changes:

When selecting a page range when printing PostScript files only the selected range will be shown in the PostScript page selection dialog. This facilitates for instance to print all odd pages in a given range.

No initial <CR> is sent when the eof-file option has been turned off. This was not the case in version 1.0 which could sometimes confuse PostScript printer with automatic sense of PostScript files (looking for an initial "!PS Adobe" ).

The /p qualifier has been removed. Use named settings through the /n qualifier instead.

Settings from 1.0 are not recognized in 2.0


Installation

Requirements

PrintFile requires a PC running one of the following versions of Microsoft Windows:

º  Windows 3.1

º  Windows 3.11

º  Windows 95 or later

º  Windows NT 3.51 or later

º  Windows 2000

No version of PrintFile can be used on OS/2.

PrintFile is delivered as a zip file archive. Two different archives are available, one with both a 16-bit and a 32-bit version of PrintFile, and another that only contains the 32-bit version.

How to install PrintFile

In order to install PrintFile you first have to unzip the contents of the PrintFile zip archive file into a temporary directory. Then run the setup program. When the installation has finished you can remove the temporary directory. If you are using WinZip you can do all this just by pressing the install button in that program.

If you are using the combined 16 and 32 bit archive the installation program will choose the correct executable for the operating system that you are installing on.

The installation will prompt you for a directory to install PrintFile into and if a Program Manager group should be created. In Windows 9x, NT 4 and 2000 a startup menu item will be created instead. In those Windows versions you also have the option to create a desktop shortcut for PrintFile. The dialog also contains a list of file types that can be associated with PrintFile. Double clicking on a file of that type in File Manager or Explorer will automatically launch PrintFile.

How to remove PrintFile

Should you want to stop using PrintFile then it is very easy to remove it. Just select the Uninstall PrintFile icon in the Program Manager / startup menu item. When using Windows 9x, NT 4 or 2000 it is also possible to do this in the Add/Remove programs dialog in the Windows Control Panel. When uninstalling you have the option to save the settings ini-file. Only files created by the installation program will be removed. If the PrintFile directory contains other files, these and the directory will have to be removed manually using the File Manager or the Windows Explorer.

Manual installation and uninstallation

If you don't like installation programs it is very easy to install PrintFile manually as well.

The archive has the following contents:

README.TXT	A short description in text format
PRFILE.EXE	Executable for Windows 3.1 and 3.11
PRFILE32.EXE	Executable for Windows 9x, NT and 2000
PRFILE.HLP	Windows Help File (this file)
PP.TXT	Pretty print definitions

Unzip the archive into a new directory e.g. C:\PRFILE . Depending on which version of Windows that you are using, you can then remove the obsolete executable. Please note that it is important to select the correct executable, it will not run on another operating system than the one it was intended for.

For convenient use you can then create a program manager icon (Windows 3.1x and NT 3.51) or a Taskbar menu item (Windows 9x, NT and 2000) for the executable. When Windows 9x, NT and 2000 it might be a good idea to create a desktop shortcut to PrintFile to be used for easy Drag and Drop printing. This can also be done directly from within PrintFile in the Settings dialog.

To uninstall PrintFile just delete the directory that you created during the installation. If you created Program Manager icons or shortcuts just remove them as well. If there is a file named PRFILE.INI in the Windows directory, it should also be removed. If you have created special PrintFile shortcut files and stored them in another directory than PrintFile, remove these as well.


Printing Files

PrintFile usage is very simple and straightforward. When started, PrintFile shows a main dialog box with some buttons and an operation status field. To print just press the Print File... button or Drag and Drop files onto the program main dialog box.

When pressing the Print File.. button the standard Windows file selection dialog box will be displayed. Select a file to be printed. It is also possible to select multiple files in the dialog. An alternative approach is to select files to be printed in the Windows File Manager or the Windows 95 Explorer and then Drag and Drop the files from here onto PrintFile's main dialog box.

The standard dialog box contains predefined extensions for PostScript and Encapsulated PostScript files. Please note however that the file extension is not significant. PrintFile analyzes the content of the file to determine what type it is.

When file selection has been made the next thing that happens is that the standard Windows printer selection dialog box is shown. Here it is possible to select which printer that the file(s) should be sent to. It is also possible to choose the number of print copies that should be made. When printing text files the Options button can be used to set printer driver specific settings. The printer selection dialog is only shown once when printing multiple files. The dialog box can be disabled in the Settings dialog in case no printer selection is wanted and the default printer always should be used.

Press the Settings... button to activate the dialog box controlling the preferences in PrintFile.

The About... button activates a dialog box with PrintFile version information.

During printout the status field shows the name of the file that is currently being printed. As long as the printing continues the Stop button is enabled. Press it to cancel printing.

If the right mouse button is pressed a popup menu will be displayed. This menu contains some additional commands e.g. to print the contents of the clipboard and to change the appearance of the PrintFile main window.

When printing multiple page DSC compliant PostScript files the page range selection field in the printer selection dialog box is also activated. Here the number of pages is shown. In this standard dialog it is only possible to select one simple range of pages. Therefore, if the radio button for page range printing is selected, a new dialog box will be shown after this dialog box. Here it is possible to select a more complex range of pages. Note that this dialog box will only be shown if the page range radio button is selected. The dialog looks like this:

The page selection list box shows the field from the DSC page comments. These normally have two fields. The first field is a label that can contain an arbitrary text field that might vary between applications that create PostScript files. The second field contains the actual page number. This dialog box can also be disabled in the PostScript Settings dialog. Hold down shift or control keys to do more complex selections.


PrintFile Settings

PrintFile has a number of settings (preferences) that can be changed in order to control the behavior of the program. The settings are controlled by a dialog box, which is activated by pressing the Settings... button in the main dialog box. The settings are specified using several different dialog boxes.

Different sets of settings can be defined and each set can be given a unique name. The set to be used can be selected in this dialog box or by a qualifier on the command line that invokes PrintFile. All this facilitates creation of drag and drop icons or commands for printing with specific options without having to change the settings each time.

Current Settings

This combo box shows the name of the current set of settings. Entering a new name here creates a new set of settings. When pressing the Save button the settings are saved with the name given in this combo box. When several sets of settings have been defined, one of them can be selected.

General

Enable spooler function

This box must be checked in order to use the /s qualifier that makes PrintFile act like a print spooler.

Show printer selection dialog

This option disables the standard Windows printer selection dialog box. In this case the printer name given in the Printer combo box below will always be used.

Show this dialog when drag and drop

When this box s checked the settings dialog will be shown every time files are dragged and dropped on PrintFile or when file names are given on the command line. This can be convenient to use together with the Apply button in order to do minor adjustments to the settings.

Quit when handled command line

Means that PrintFile will always quit after it has printed the files provided on the command line that invoke it, i.e. after initial drag and drop or command line activation with file parameters.

Show settings name in header

If checked the name of the current selected set of settings will be shown in the header of PrintFile main dialog box.

Show progress bar

When this option is checked a dialog box with a progress bar will be shown while a file gets printed. When several files are being printed the order number of the current file and the total number of files will also be shown. This option is only available in Windows 95 and NT 4.0 or later.

Save window placement on exit

Means that the PrintFile main window placement (position, on top option and window type) is saved whenever the program is terminated. The next time PrintFile is started using this set of settings, the window placement will be restored.

Show icon on the taskbar

When this option is selected PrintFile will create an icon in the part of the task bar that is sometimes referred to as the “system tray”. Clicking on this icon using the left mouse button will toggle visibility of the PrintFile main window. Using the right mouse button on the taskbar icon will pop up the main menu. Another effect of this option is that the main window is hidden when minimized. Clicking on the icon will make it visible again.

This option enables quick access to the program and its menu.

Mandatory for file type(s):

In this text input field it is possible to enter the name or names of specific file extensions (the name after the last dot in file names). Whenever a file matching any of the specified extensions is printed by PrintFile, this set of settings will always be used regardless of the current settings. Multiple extensions must be separated by “;”. Example: “.txt;.log”

Printer

This drop down list contains the names of all printers installed in Windows. Use default means that the default standard printer selected in the Windows control panel will be used. To enforce use of another specific printer, make a selection from the names in this drop down list. If the Show printer selection dialog is enabled, the printer selected here is the one that is the default in the printer selection dialog box.

Note: If a specific printer is selected in the 16-bit version of PrintFile and the Show printer selection dialog option is enabled, PrintFile also changes the default standard Windows printer to this value. This is due to the limitations of the standard printer selection dialog in Windows 3.1x.

More

This group contains button that activates additional settings dialogs. Available choices are:

Text file

PostScript

N-up

Conversion

Save

Saves the current settings under the name given in the combo box. This name can be used in subsequent runs of PrintFile.

Apply

Uses the current settings during the current run of PrintFile. The settings are not permanently saved and will be lost when the program terminates. This can be useful when just minor temporary changes should be made to a permanent set of settings.

Shortcut...

By pressing this button, Windows 95 and NT 4 shortcuts to PrintFile, with the specified named settings activated, can be created. When doing so the Shortcut dialog will be shown.

Delete

To delete a set of settings select the name and press this button. Note however that the "Default settings" can't be deleted.


Text file settings

This dialog box controls the layout when printing text files. The layout is also always partly controlled by the n-up printing settings dialog. Available options are:

Text file action

This radio button group specifies what to do with text files.

Print formatted means that text files will be printed with n-up and the formatting options specified below.

Send to printer means that the file will be sent, as it is without any formatting, to the printer

Ignore can be used to disable all printing of text files.

Formatting options

If Print formatted has been selected the following options can be specified:

Size is a group that controls the font size used on a page. It is possible to specify either the number of lines that should fit into one logical page and/or the number of characters that should fit into one line of text. If only one value is specified the other one is implicit based on the default character ratio in the font. If both values are specified however, the character ratio will be adjusted accordingly.

Tab width is the number of spaces used to represent a tab position.

If Wrap long lines are checked all lines that are too long to fit on a single line will be word-wrapped into several lines. If not checked, such lines will be truncated and a truncation mark will be placed to the right of the line.

Show line numbers can be checked to get the line number placed to the left of each line, e.g. suitable for program listings.

Pretty Print enables a function for highlighting specific words and combinations in a text file. The rules for this highlighting are defined in a Pretty Print definitions file.

OEM translation means translating MS-DOS 8-bit characters to their corresponding Windows equivalents. If the automatic option is checked PrintFile scans the file for characters in the ASCII range 128-165 and if any such characters are found the file will be translated. If no characters are found no translation is made and this means that it's safe to use this option also when printing a mix of MS-DOS and Windows files.

Font is the text font used when printing the text lines. Only monospaced fonts can be used. The list contains all such fonts that are installed in the system.

Header and Footer can be used to get content-related information on each logical or physical page. Normal text can be mixed with the following special character sequences to insert the corresponding information automatically

To Print	Use

File name	&f
Full file path	&p
File modification date	&d
Page number of current page	&#
Total page count	&t
Left aligned	&l
Centered 	&c
Right aligned	&r

Example:

&f&c&d&rPage &#(&t)

This will print the name of the file left aligned, the file modification date in the middle and the text Page followed by current page number and total page count within "( )"  right aligned on each page.

Paper bound header and footer means that a header and/or footer will be placed on each paper page, outside the logical pages. If this option is checked the translation of the page number related special characters, described above, will use the actual physical page numbers and NOT the logical page ones.


Pretty Printing

PrintFile has the possibility to highlight specific words and combinations when printing text files. This function called Pretty Print is mainly intended to be used for program source code files but might as well be used on any text file. Different rules for highlighting can be defined and rule selection is based on the extension (type) of the file being printed. There is no dialog for defining the rules, they have to be entered in a text file with a specific syntax. The default definitions file is named pp.txt and should be located in the same directory as the PrintFile executable file. Other definitions files can be used through the /p qualifier on the command line. In order to activate Pretty Printing this option must be checked in the text file settings dialog.

The syntax for the Pretty Print definition rules is quite simple. A rule consists of a number of definition lines. Each definition line starts with an upper case definition identifier followed by a ”=” and a value for this identifier. All lines that do not follow this syntax are ignored and can e.g. be used as comments. The first line in every rule is defining the type of files that this rule should be used for. This definition identifier is mandatory whereas all others are optional.

The default pp.txt, supplied in the PrintFile distribution, contains rules for some common programming languages (C, C++, Java, Pascal and Perl).

Below is an example for files written in the C programming language. This definition is present in the default pp.txt. If you want to add new rules or change the default ones, just edit pp.txt or create an alternative definitions file.

Example:

TYPE =.c|.h
KEYWORDS = auto break case char const continue default do double else\
enum extern float for goto if int long register return short signed\
sizeof static struct switch typedef union unsigned void volatile while
KEYWORD-STYLE = bold
KEYWORD-COL = 0,0,255
COMMENT-START = /*
COMMENT-END = */
COMMENT-SINGLE = //
COMMENT-STYLE = italic
COMMENT-COL = 0,255,0

Description of rule identifiers

TYPE
This identifier starts a new rule definition. The value is the extensions for files to be printed using this rule. Different file types are separated with the | character.

KEYWORDS
The value here is a list of reserved keywords that are to be highlighted within the text file. The value can span over several lines if the each continuing line is terminated with the \ character.

KEYWORD-STYLE
This value controls the font style used when drawing any of the above specified keywords. Valid values are: bold, italic, and underline. One or more of these values can be given. Spaces or commas must separate multiple values.

KEYWORD-COL
If a specific color is to be used for highlighting keywords on a color capable printer it can be specified here. The value is the red, green and blue components of the color in the range 0-255, separated by commas.

KEYWORD-CASE
Controls if case sensitive matching of keywords should be made. Valid values are yes and no (lower case). Default is yes. If used, this line MUST be placed before the KEYWORDS definition.

COMMENT-START
Source code comments is the other entity that can be highlighted in a text file. This value defines a character sequence that starts a comment. This kind of comment can span over several lines in the source code file and is terminated by the next definition: COMMENT-END.

COMMENT-SINGLE
This value is used to define a character sequence that identifies a comment that only lasts to the end of the current line.

COMMENT-STYLE
Font style to be used for comments, same syntax as for KEYWORD-STYLE .

COMMENT-COL
Color to be used for comments, same syntax as for KEYWORD-COL .

COL-ON-BW
Use this identifier if you want to use the highlight color definitions also on printers without color capability in order to get a gray scale. Valid values are yes and no (lower case). Default is no.

TAB-WIDTH
Specific tab width used for this type of file (overrides the default setting from the text file settings dialog).


PostScript settings

This dialog box shows the PostScript-specific user configurable settings. Available options are:

General

Use end of file character (^D)

Check this box in order to make PrintFile add the PostScript end of file character (ASCII 04) first and last in the data sent to the printer. This option should normally be checked except when printing PostScript files created by the HP LaserJet drivers. The reason for this is that these files contain some initial lines of non-PostScript code that change the printer mode. Mixing this with the PostScript end-of-file character confuses the printer and no printout will be produced.

Enable page selection

When this box is checked PrintFile looks for DSC compliant PostScript files before the printing starts. When such a file is found PrintFile counts the number of pages and enables printing of page ranges. Uncheck this box to speed up printing when no range selection is wanted.

Include driver header

Means that the header (PostScript prolog) from the Windows PostScript printer driver will be sent to the printer before the actual PostScript file. This can be used to apply PostScript settings from the Options dialog in the printer selection dialog. The driver prolog might very well interfere or conflict with the contents of the PostScript file so this function is not guaranteed to work. Selected options might also be overruled by options already present in the PostScript file.

Enable n-up printing

Activates n-up printing of PostScript files. Please note that n-up printing ONLY works if the file is DSC compliant and if the printer supports PostScript level 2. If either of these conditions does not apply then the file will be printed with its original size and position. If Ghostscript is used as a conversion program n-up printing will work. Please note that this option affects all PostScript printing, also if n = 1.

Warn for non-PostScript printers

PostScript files can only be printed on PostScript printers. If this box is checked then a warning dialog will be shown when an identified PostScript file is about to be sent to what does not appear to be PostScript printer. This is to avoid the problem with large text printouts of PostScript code. There is however no real foolproof method to detect if a printer driver supports PostScript or not. Some HP LaserJet printers for instance, accept PostScript code sent through the PCL driver. No warning will be show if a conversion program has been specified for PostScript files in the conversion settings dialog.

Prolog file

Here it is possible to select a PostScript file which will be sent before the actual PostScript or Encapsulated PostScript file. This can be used to set printer specific options like tray or size selection or to modify the behavior of an EPS file. Use different files for different settings. Use the browse button to search for a file or enter the file name directly in the edit field. More details about possible prolog file contents can be found here.

Encapsulated PostScript

Encapsulated PostScript files always have a bounding box comment which describes the size and position of the picture. This information can be used by PrintFile to position the picture on the page when printing. The following options are available:

º  Keep original size and place: No change is made the to the PostScript coordinate system, the picture is printed "As is"

º  Center on page: The coordinate system is changed in order to place the picture in its original size in the center of the printer page.

º  Center and scale to fit page: Same as above but the size of the picture is changed so that it fits the size of the printer page. Equal x and y scaling is used, i.e. no distortion of the picture.

Frame bounding box

Check this box in order to get a frame around the picture bounding box. The frame width is controlled by the value for frame width in the n-up settings.

Print file name

When checked the name of the EPS file is printed in the upper left corner of the paper. Convenient when printing a batch of EPS files.


Document Structuring Conventions (DSC)

Adobe has defined a set of extended comment conventions that provide additional information about the page structure and resource requirements of a PostScript file. If a file contains these Document Structuring Convention (DSC) comments, PrintFile can let the user select sub ranges of pages for printing and also apply PostScript code for n-up printing.

If a file does not contain DSC comments, PrintFile can only print all the pages and no n-up printing is possible. DSC compliant files start with the comment line:

 %!PS-Adobe-3.0

where the number 3.0 may change and is the DSC version number. PrintFile accepts initial non-PostScript data before the %! line. This data will be skipped when the file is sent to the printer. This can be practical as some printer drivers add control-D or some printer specific, non-PostScript, code before the actual PostScript code.

DSC compliant files contain lines such as:

%%Pages: 24
%%Page: 1 1

These lines tell PrintFile how many pages a document contains and where they start. PrintFile uses this information to select individual pages.


PostScript prolog files

General use of prolog files

PostScript prolog files can be used to add PostScript code for selection of printer specific options like tray and size. There is however no code that is guaranteed to work on all printers, every printer manufacturer might use their own names. Most printers support the code below though. Change XXX to something like letter, legal, 11x17, A4 or whatever (always use lower case characters), it usually works. Save this line in a text file and use this file as a prolog file.

statusdict /XXXtray get exec

Another useful option is selection of duplex printing. This can normally be achieved by the following piece of PostScript code:

<< /Duplex true >> setpagedevice

Prolog files for EPS printing

The following section is intended for people with knowledge of PostScript programming.

Prolog files can also be used to add or change the functionality when printing EPS files with PrintFile. In the prolog file the following hook procedures can be added:

prf_frame_hook

prf_header_hook

prf_frame_hook is called before the frame is drawn and can for instance be used to set an alternate line width for the frame. Example:

/prf_frame_hook { 5 setlinewidth} def

prf_header_hook is called before the header is drawn. Can be used to add additional information in the header or to place it somewhere else on the paper.

A procedure named prf_bbox can be called to get the coordinates for the bounding box on the stack.

To get a listing of the EPS printing procedures, or the n-up printing procedures, do a printout to FILE: and view the result of the generated file.


Printing to a PostScript file

It is possible to redirect printout from any Windows program to a PostScript file instead of a printer. This file can later be used to get an n-up printout using PrintFile.

To achieve this a PostScript printer driver has to be installed and connected to FILE: instead of a printer port. It is very important to make sure, when using Windows 95 or Windows 3.1x PostScript drivers, that the Optimize for portability option in the driver is enabled. In NT 4.0 the corresponding option is called Page independence. If this option is not enabled, n-up printing of these files will probably not work.

Whenever this printer driver is used from a Windows program, a prompt for a name of a PostScript file will be shown. When the file has been created, use it as an input file to PrintFile just like any other PostScript file.

Another very convenient option is to use PrintFile together with Russell Lang's printer redirection monitor RedMon, available from:  http://www.cs.wisc.edu/~ghost/redmon . Using RedMon and PrintFile's option to read its data through a command line pipe, gives you the possibility to print from any Windows program using PrintFile specific options.


N-up printing settings

The option to place several logical pages on one physical page is called n-up printing. This is always used for text file printing and can also be used for DSC PostScript files when printed on printers which supports PostScript level 2 or when using a conversion program for PostScript files. Note that n-up printing of PostScript files must be enabled in the PostScript settings dialog.

The following options controls the n-up layout:

Layout

This group contains settings that controls how logical pages are arranged on one page of paper. Page width is the number of logical pages that are arranged horizontally. Page height is the number of pages placed vertically. The orientation of the pages can be either Landscape or Portrait. The placement order of the logical pages can be either Horizontal or Vertical.

A frame can be drawn around every logical page with the given width. If width is set to 0 then the actual width will be the thinnest possible on the printer.

To get the often-used 2-up function for instance, use a page width of 2 and page height of 1 in landscape mode.

Please note that width and height of course both can be set to 1 in order to get a normal printout with only one logical page per physical page.

When doing n-up printing of PostScript files the original page ratio is always maintained and the contents is centered within the logical page.

Margins

The paper margins between the paper edges and the logical pages are specified in this group. Left margin is always the margin from the portrait left side of the paper. The default left margin is larger than the right margin in order to make room for possible paper holes.

Gutter is the distance between the logical pages.


Conversion settings

This dialog box is used to specify how and when PrintFile should run another program to convert a file before it is being printed. This can for instance be used to let Ghostscript convert a PostScript file into another printer format. The converted file will then be sent to the printer instead of the original.

The principle for the conversion is that PrintFile will supply the conversion program with the name of the original input file and the name of a temporary file that the program should create. If the output file does not exist after the conversion or if it is empty PrintFile assumes that the conversion has failed.

Enable conversion of :

Enables use of a conversion program for the specified type of files. PostScript files means all type of PostScript files i.e. DSC, non-DSC and EPS.

Program

Enter the name of the executable file to run or find it using the file browser.

Parameters

Here the parameters for the conversion program should be specified. On this parameter line the following macros can be used:
&i : the name of the input file
&o : the name of the converted temporary file used for output by the conversion program.
&p : the name of the printer used in the current settings.

Please note that when running Windows 3.1x the system (DOS) has a limit of 128 characters on a command line. This limit can easily be exceeded when the program name and the macros are expanded. If the conversion program can accept parameters through a parameter file (as Ghostscript can) PrintFile can be instructed to create such a file. If the first character on the parameter line is a @ character PrintFile will save the parameter line to a file and the program will be launched with only the name of the parameter file (with a @ prefix) on the command line. If the conversion program can not handle parameter files a solution might be to encapsulate the command in a bat-file and specify this bat-file as the conversion program in this dialog.

Show conversion program window

This option should normally not be checked to avoid windows popping up and down every time a conversion is made. It can however be convenient to use when testing or debugging a conversion in order to see possible messages from the conversion program. If this options is not checked the conversion will run invisible in the background.

Conversion program handles printing

When this option is checked PrintFile will not print the file after the conversion program has terminated. This option is primarily intended to be used together with the generic Windows printer driver mswinpr2 in Ghostscript.

During the conversion process PrintFile creates one or more temporary files.

The default directory for the conversion program is the directory where the program is located.

The conversion function is mainly intended for use with Ghostscript but can of course also be used for many other type of conversions. Specifying the parameters for Ghostscript is not trivial but please do not ask me about it. Instead check the Ghostscript documentation or even better the excellent Ghostscript manual written by Thomas Merz. This manual is available form the Ghostscript homepage at: http://www.cs.wisc.edu/~ghost/

Example for Ghostscript conversion

Assuming that you have a LaserJet 4 printer and used the standard installation of the 32-bit Ghostscript version 5.03 using GSview and installed to c:\gstools, the following program and parameters can be used:

Program:
c:\gstools\gs5.03\gswin32.exe

Parameters:
-Ic:\gstools\gs5.03;c:\gstools\gs5.03\fonts -dNOPAUSE -sDEVICE=ljet4 -sOutputFile=&o &i -c quit

For Windows 3.1x the program should be the DOS executable gs386.exe and the parameters should be prefixed with a @ character in order to avoid the command line limit of 128 characters

If you want to use the generic Windows printer driver mswinpr2 instead, the following parameters should be used:

-Ic:\gstools\gs5.03;c:\gstools\gs5.03\fonts -dNOPAUSE -sDEVICE=mswinpr2 -sOutputFile="\\spool\&p" &i -c quit

Please note the quotation marks around the sOutputFile value. The Conversion program handles printing option must also be checked in this case.

Example for printing HPGL files on a LaserJet printer

Create two different text files called beginhpg.txt and endhpg.txt. In the first one enter the following text:

<ESC>%0B

This will set the printer to HPGL mode.

In the second file enter the following text:

<ESC>%0A

This will make the printer leave HPGL mode. <ESC> is the escape character ASCII 27 (0x1B).

Then enter the following in the setting dialog.

Program:
command.com

Parameters:
/c copy  XXX\beginhpg.txt+&i+XXX\endhpg.txt &o

XXX is the directory where the two text files were stored.

Enable this conversion for text files.


Temporary files

PrintFile sometimes creates temporary files on disk. All files will be placed in the system temporary directory. This directory is indicated by the environment variables TMP or TEMP. If none of these environment variables are defined the files will be placed in the root directory of the default drive. All temporary files are normally deleted. Should the program or the system crash during an operation they might be left. Temporary files are only created when printing the clipboard, standard input and when running a conversion program.


PrintFile Shortcuts

This dialog handles creation of Windows 95 / NT 4 shortcuts to PrintFile. The created shortcuts will launch PrintFile with the selected named settings as default.

When creating shortcuts in the Windows shell a bug (feature?) makes it impossible to use command line qualifiers when doing drag and drop. In the shortcut properties dialog it is possible to add qualifiers to the program. These will be present on the command line that invoke the program. When doing drag and drop however, Windows just throws these qualifiers away from the command line. The reason for this is unknown to me, but that the way it is. In order to avoid this, PrintFile creates a very small application that launches PrintFile with a qualifier that selects the desired named settings. The shortcut points to this application and this makes the drag and drop function work as expected.

Enter the name you want to use for the shortcut in the Name edit field, and select whether a Desktop or Send to shortcut should be created in the Type group. Storage directory is where the corresponding small applications described above should be stored. Default location is a sub directory named shortcuts in the directory where the PrintFile application is residing.

Desktop shortcuts are intended for easy drag and drop printing directly from the desktop

Send to shortcuts are very convenient as you can easy select file(s) in the Windows Explorer and then use the Send to entry in the object menu to print the file(s) through PrintFile with a specific set of preferences used.

If a non-standard ini-file was selected through the /i command line  qualifier, this ini-file will be used by the shortcut as well.


Command line usage

PrintFile can be controlled by adding parameters to the command line that invokes it. The parameters are interpreted as file names and these files will be printed. File names can be given with wildcard characters and in this case the wildcards will be expanded.

Instead of supplying a lot of file names on the command line when printing a batch of files an alternative method can be used. Create a text file with the name of each file on a separate line. Supply the name of this list file on the command line but prefix the file name with an @. In this case PrintFile will open the file and the whole batch of files will be printed one by one.

Note that file names that contain spaces must be surrounded with quotes.

When command line parameters are present the program always terminates after printing the files if the entry Quit when handled command line in the Settings dialog is set.

The command line can also contain program qualifiers. These must be given before any possible file names. The following qualifiers are recognized:

/n:settings-name

Selects the named settings given by settings-name as default. Please note that settings with a name which contains spaces must be surrounded with quotes e.g. "/n:Default Settings".

/s:wildcard

Starts PrintFile as a spooler and watches for files matching wildcard. All files matching the wildcard will be printed and then deleted. The spooler function must first have been enabled in the Settings dialog. In this case a log file with possible error messages will always be created.

Please read the warnings about this function here

/e

Writes time stamped messages of errors and the start and finish times of printed files to a log file. Using this qualifier makes it possible to get a log file also when not running as a spooler.

/l:logfilename

Defines the name of the log file. If not present the name of a possible log file will be PrFile.log in the Windows directory. This qualifier is ignored unless the /s or the /e qualifier also is used. If the file name is prefixed with a "+" character the messages will be appended to an already existing log file, otherwise the old file will be overwritten.

/b:backupdir

Use this qualifier together with the /s qualifier to specify a backup directory which each file will be copied to before it is deleted from the spool directory. The directory will be created if it does not exist.

/q

Quiet mode. No main window will be shown. The files will just be printed according to the given settings specification or the default settings. When all files have been treated, the program will terminate.

/i:ini-filename

Use a specific ini-file. This qualifier can be used to force PrintFile to use another ini-file than the standard prfile.ini in the Windows directory. This can be convenient when you want to use e.g. a standard set of settings stored on a server. If a shortcut is created it will also refer to this ini-file. Please note that this qualifier must come before a possible /n qualifier.

/c[:name]

Prints possible text contents on the clipboard and quits. The optional value name can be used to control the name used in possible header and footer. Please note that this name has to be a legal file name for the current operating system.

/-[:name]

Prints data from standard input (e.g. command line pipe) and quits. The optional value name has the same function and restrictions as the one for clipboard above.

/p:ppdef-filename

Use a specific Pretty Print definitions file.

/delete

Deletes each file specified on the command line after it has been successfully printed. USE WITH CARE !!!!

/#:count

Specifies the default copies count when printing files.


PrintFile popup menu

The PrintFile popup menu contains the commands available in the standard dialog box and some additional commands. This menu is displayed whenever the cursor is placed within the PrintFile window and the right mouse button is pressed.

Print clipboard

This menu item is used to print the contents of the clipboard in the same manner as a text file is printed. The current text file settings is used for the printout. If the clipboard contains no text data this item is dimmed.

File information...

Use this item to let PrintFile analyze a file and show possible information about PostScript, EPS, file size and the number of printer pages required for a printout.

Settings

Through this menu item it is possible to select a named set of setting without entering the settings dialog. The Change command however activates the settings dialog.

Window type

This item is used for changing the appearance of the PrintFile main window. There are three different window types that can be used. The normal standard dialog box with status field and buttons is the default. The second type, called Minimal, is a small minimal window containing only the PrintFile icon. This window has a title bar and can therefor be moved around on the screen. The third type is also a minimal window but without a title bar. This window, called Fixed minimal, can not be moved. In order to move it the second type must first be chosen. The position for the Fixed minimal window always follows the position of the Minimal. The initial placement for the minimal windows is the upper right corner of the screen. As the minimal windows has no buttons the popup menu has to be used for all commands and to stop a printing.

Always on top

 If this option is enabled the PrintFile window will always be on top of all other windows. This is the default for the minimal window types, thereby making them easy to find for drag and drop operations.


Run PrintFile as a print spooler

It is possible to let PrintFile act as a print spooler, watching a specified directory for files. Whenever a file appears in this directory it is automatically printed and then deleted. This can e.g. be used to dedicate a PC running PrintFile to act as a print server for a network. Clients can then use ftp or LAN-manager services to send their files to the dedicated PrintFile spool directory. When the files arrive they will be printed automatically. When this function is activated no error dialogs will be displayed. Instead all error and warning messages will be sent to a log file in the Windows directory named PrFile.log unless the /l qualifier is used on the command line. This file contains time stamped messages.

When this function is activated PrintFile shows a different dialog box which always starts minimized.

The function is activated using the /s a qualifier on the command line that starts PrintFile. The function must also first be enabled in the settings dialog. To facilitate the start of this function create a bat file or a shortcut with a contents like this:

"C:\Program Files\PrintFile\prfile32.exe" /s:c:\spool\*.ps

Note the quotes if the program is installed in a directory path containing spaces.

!! WARNING !! WARNING !! WARNING !!

DO NOT use this function unless you know exactly what you are doing. Please note that PrintFile actually DELETES the files after they have been successfully printed. It is therefore VERY IMPORTANT that the path parameter is valid and that possible wildcards do not expand more than you expect. However, if the /b qualifier is used, a backup copy of the printed file will be made to the specified directory before it is deleted form the spool directory. Note though that if a file with the same name is already present in the backup directory, it will be overwritten. The file will also be deleted from the spool directory even if PrintFile fails to make a backup copy.


Frequently asked questions

Here are some of the most frequent questions I have been getting about PrintFile:

Q: Why does PrintFile print my PostScript file (in A4 size, using upper tray, etc.) when I have selected something else in the Properties dialog?

A: PrintFile normally just sends a PostScript file as it is directly to the printer. The standard Windows Printer dialog is just there to let you select which printer to use and the number of copies to print. All other options are ignored. Therefore in version 2.0 the Options button has been disabled when printing PostScript files. The only possible way to select printer specific options is to define a PostScript prolog file in the PostScript Settings dialog. However, starting in version 2.1 it is possible to enable the printer header to be included in the output. In this case the Options button is enabled and the selected options will be present in the driver header. Please note that this is not guaranteed to work as the driver header might conflict with the contents of the PostScript file.

Q: Why do I just get the PostScript text when I try to print a PostScript file on my printer?

A: The most common answer to this is that the printer is not a PostScript printer. PrintFile is not a PostScript rendering program, it only sends PostScript files to the printer as they are. If you want to print PostScript files on a non-PostScript printer you must have a program that can handle this. A very good one is the combination Ghostscript and GSview, available from http://www.cs.wisc.edu/~ghost/
Version 2.1 also has the possibility to let PrintFile run Ghostscript automatically in order to convert a PostScript file to another format that the non PostScript printer can understand.

The default behavior is to show a warning when sending a PostScript file to a non-PostScript printer unless a conversion program has been specified.

Q: Why does not n-up printing work on my PostScript file created from Word using the standard PostScript driver?

A: The PostScript driver must be properly configured to create PostScript files that can be used for n-up printing.

Q: Why can't I print my Word, Excel etc. files with PrintFile?

A: PrintFile can only print text, PostScript and files produced by a Windows printer driver.

Q: Can I have the source code for PrintFile?

A: No. Although PrintFile is freeware the source code is not in the public domain.


Technical Information

PrintFile is implemented using the Visual C++ environment. Version 1.52 is used for the 16-bit version and version 6.0 for the 32-bit version. The implementation is a standard Windows program without MFC.

The 16-bit version of PrintFile uses the printer driver API routines OpenJob, WriteSpool and CloseJob to send files to a printer. The 32-bit version uses the standard Win32 API routines OpenPrinter, WritePrinter and ClosePrinter. A very special thanks to Russell Lang for supplying me with the information about the undocumented API for the 16-bit solution.

The reason that some Win32 fanciness, like tab control, registry usage, Help Engine 4 and alike, are missing is that I have tried to keep a common source code base for both the 32-bit and 16-bit versions.


Legal Issues

Distribution

PrintFile is freeware i.e. you can use it free of charge and no registration is required. If you however find any use for this program it would be very interesting for me, Peter Lerup, to know. Please send a mail to the address listed here or preferably send me a nice postcard of your hometown. Also if you feel that this program is very useful, perhaps saves you time and money, and subsequently would like to make a donation, I would of course welcome this.

Even though PrintFile is freeware, it is not in the public domain, I reserve all rights to it. You may freely distribute copies of PrintFile as long as you do so in an unmodified form and include all files and documentation that are present in this archive. You may not charge for the distribution of PrintFile other than a reasonable fee to cover your distribution costs.

The program may not be bundled with any kind of commercial products without the express permission from me. Bundle licensing prices are available on request.

Distribution on SimTel CD-ROMs is permitted.

DISCLAIMER OF WARRANTY.

SINCE THE SOFTWARE IS PROVIDED FREE OF CHARGE, THE INFORMATION AND CODE PROVIDED IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. UNDER NO CIRCUMSTANCES SHALL PETER LERUP BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF PETER LERUP HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.

Trademarks

PostScript is a registered trademark of Adobe Systems.
Microsoft, Windows, Windows 95, Windows 98, Windows NT and Windows 2000 are registered trademarks of Microsoft Corporation.
Macintosh is a registered trademark of Apple Computer.


PrintFile Author Peter Lerup

If you have suggestions, messages or bug reports, the author Peter Lerup can be reached at the following address:

E-mail:	peter@lerup.com
WWW:	http://www.lerup.com/printfile

Check out the web site above for the latest information about PrintFile.

If you are kind enough to send a postcard, this is the snail mail address:

Peter Lerup
Båtbyggaregatan 144
S-216 42  MALMÖ
SWEDEN

Credits

Ideas

A very special thanks to Folke Larsson for testing and exchange of ideas on design and layout.

Many thanks also to Russell Lang for ideas and for supplying me with information and of course for the excellent freewares GSview and RedMon.

Money!

My greatest appreciations to Xerox and Rick Born there for buying a substantial commercial license for PrintFile.

Thanks also to those of you who have been buying smaller enhancements or specific functional updates of the program.

Common gratitude

Thanks to everyone who have sent me kind words of appreciation and especially to all of you who sent me postcards.